from random import *
n = 0
while True:
      try:
            n += 1
            s2 = eval(input("请猜数:"))
      except:
            n += 1
            s2 = eval(input("请重新猜数，需要输入的是数字:"))
      finally:
            s1 = randint(0,9)
            if s1 > s2:
                  print("很遗憾，太小了")
            elif s1 < s2:
                  print("很遗憾，太大了")
            else:
                  print("预测{}次,你猜对啦！".format(n))
                  break
